﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EasyWindowsServiceManager.Forms
{
    public partial class MainForm : Form
    {
        private int childFormNumber = 0;



        public MainForm()
        {
            InitializeComponent();
        }

        #region Form and controls events (TODO: Pendiente revisar)
        /// <summary>
        /// Nuevo Formulario
        /// </summary>
        private void ShowNewForm(object sender, EventArgs e)
        {

            Dialogs.DialogBase db = new Dialogs.SetComputerToConnect();
            if (db.ShowDialog(this) == DialogResult.OK) {
                string computerToConnect = (String)db.returnValue;
                if (!String.IsNullOrEmpty(computerToConnect)) {
                    MessageBox.Show("Conectando al computador: " + computerToConnect);
                    Form childForm = new Forms.ListServices(computerToConnect);
                    childForm.MdiParent = this;
                    childForm.Text = "Ventana " + childFormNumber++;
                    childForm.Show();
                }
            }
            
        }


        /// <summary>
        /// Guardar lista de servicios
        /// </summary>
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter = "Archivos de texto (*.txt)|*.txt|Todos los archivos (*.*)|*.*";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = saveFileDialog.FileName;
            }
        }
        /// <summary>
        /// Imprimir lista de servicios
        /// </summary>
        private void printToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Todo
        }

        /// <summary>
        /// Mostrar dialogo Acerca de
        /// </summary>
        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Dialogs.AboutBox aboutBox = new Dialogs.AboutBox();
            aboutBox.ShowDialog(this);
        }

        /// <summary>
        /// Cargar formulario
        /// </summary>
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.Text = Application.ProductName;
        }

        /// <summary>
        /// Salir
        /// </summary>
        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
            Application.Exit();
        }

        #endregion


        #region Pendientes revision
        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toolStrip.Visible = toolBarToolStripMenuItem.Checked;
        }

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }


        #endregion







    }
}
